﻿using System;
using System.Collections.Generic;
using System.Security.Claims;
using System.Security.Principal;
using System.Text;

namespace socialnetworkApp.Core
{
    public static class IdentityExt
    {
        public static string GetClaimValue(this IPrincipal principal,string claimName)
        {
            var claims = (ClaimsPrincipal)principal;
            
            return claims.FindFirst(claimName)?.Value;
        }
        public static string GetUserEmail(this IPrincipal principal)
        {
            return GetClaimValue(principal, ClaimTypes.Email) ??"";
        }

        public static string GetUserId(this IPrincipal principal)
        {
            return GetClaimValue(principal, "Uid") ?? "";
        }
        public static string GetUserGUID(this IPrincipal principal)
        {
            return GetClaimValue(principal, ClaimTypes.Name);
        }
    }
}
